<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <meta name="Author" content="Ward Cunningham">
   <meta name="GENERATOR" content="Mozilla/4.5 [en]C-CCK-MCD compaq  (Win98; U) [Netscape]">
   <title>Arithmetic</title>
</head>
<body>

<h1>
Integer Arithmetic</h1>

<p>The computer relies on arithmetic. Here we test a variety of arithmetic
operations expressed as 32 bit two's complement binary numbers (Java's
int).
<br>&nbsp;

<table BORDER COLS=6 CELLSPACING=0 CELLPADDING=3 >


<tr>


<td COLSPAN="6">
eg.ArithmeticFixture
</td>


</tr>



<tr>


<td>
x
</td>



<td>
y
</td>



<td>
+
</td>



<td>
-
</td>



<td>
*
</td>



<td>
/
</td>


</tr>



<tr>


<td>
0
</td>



<td>
0
</td>



<td bgcolor="#cfffcf">
0
</td>



<td bgcolor="#cfffcf">
0
</td>



<td bgcolor="#cfffcf">
0
</td>



<td bgcolor="#ffffcf">
0<hr><pre>Error: Division by Zero<br />	at eg::ArithmeticFixture/doCell()<br />	at fit::Fixture/doCells()<br />	at fit::Fixture/doRow()<br />	at fit::Fixture/doRows()<br />	at eg::ArithmeticFixture/doRows()<br />	at fit::Fixture/doTable()<br />	at fit::Fixture/interpretTables()<br />	at fit::Fixture/doTables()<br />	at test::FrameworkTest/handleLoaderComplete()<br />	at flexunit.framework::AsyncTestHelper/runNext()<br />	at flexunit.framework::TestCase/runTestOrAsync()<br />	at flexunit.framework::TestCase/runMiddle()<br />	at flexunit.framework::ProtectedMiddleTestCase/protect()<br />	at flexunit.framework::TestResult/doProtected()<br />	at flexunit.framework::TestResult/doContinue()<br />	at flexunit.framework::TestResult/continueRun()<br />	at flexunit.framework::AsyncTestHelper/handleEvent()<br />	at flash.events::EventDispatcher/dispatchEventFunction()<br />	at flash.events::EventDispatcher/dispatchEvent()<br />	at flash.net::URLLoader/onComplete()</pre>
</td>


</tr>




<tr>


<td>
1
</td>



<td>
2
</td>



<td bgcolor="#cfffcf">
3
</td>



<td bgcolor="#cfffcf">
-1
</td>



<td bgcolor="#cfffcf">
2
</td>



<td bgcolor="#ffffcf">
0.5<hr><pre>Error: NumberFormatException: For input string: "0.5"<br />	at fit::PrimitiveFixture$/parseLong()<br />	at fit::PrimitiveFixture/checkLong()<br />	at eg::ArithmeticFixture/doCell()<br />	at fit::Fixture/doCells()<br />	at fit::Fixture/doRow()<br />	at fit::Fixture/doRows()<br />	at eg::ArithmeticFixture/doRows()<br />	at fit::Fixture/doTable()<br />	at fit::Fixture/interpretTables()<br />	at fit::Fixture/doTables()<br />	at test::FrameworkTest/handleLoaderComplete()<br />	at flexunit.framework::AsyncTestHelper/runNext()<br />	at flexunit.framework::TestCase/runTestOrAsync()<br />	at flexunit.framework::TestCase/runMiddle()<br />	at flexunit.framework::ProtectedMiddleTestCase/protect()<br />	at flexunit.framework::TestResult/doProtected()<br />	at flexunit.framework::TestResult/doContinue()<br />	at flexunit.framework::TestResult/continueRun()<br />	at flexunit.framework::AsyncTestHelper/handleEvent()<br />	at flash.events::EventDispatcher/dispatchEventFunction()<br />	at flash.events::EventDispatcher/dispatchEvent()<br />	at flash.net::URLLoader/onComplete()</pre>
</td>


</tr>



<tr>


<td>
1
</td>



<td>
-1
</td>



<td bgcolor="#cfffcf">
0
</td>



<td bgcolor="#cfffcf">
2
</td>



<td bgcolor="#cfffcf">
-1
</td>



<td bgcolor="#cfffcf">
-1
</td>


</tr>



<tr>


<td>
10000
</td>



<td>
10000
</td>



<td bgcolor="#cfffcf">
20000
</td>



<td bgcolor="#cfffcf">
0
</td>



<td bgcolor="#cfffcf">
100000000
</td>



<td bgcolor="#cfffcf">
1
</td>


</tr>



<tr>


<td>
100000
</td>



<td>
100000
</td>



<td bgcolor="#cfffcf">
200000
</td>



<td bgcolor="#cfffcf">
0
</td>



<td bgcolor="#ffcfcf">
10000000000 <font size=-1 color="#c08080"><i>expected</i></font><hr>1410065408 <font size=-1 color="#c08080"><i>actual</i></font>
</td>



<td bgcolor="#cfffcf">
1
</td>


</tr>



<tr>


<td>
1000000
</td>



<td>
1000000
</td>



<td bgcolor="#cfffcf">
2000000
</td>



<td bgcolor="#cfffcf">
0
</td>



<td bgcolor="#ffcfcf">
1000000000000 <font size=-1 color="#c08080"><i>expected</i></font><hr>-727379968 <font size=-1 color="#c08080"><i>actual</i></font>
</td>



<td bgcolor="#cfffcf">
1
</td>


</tr>


</table>


<br><br>
Now we try something similar using automatic type conversion offered by ColumnFixtures (BFL1).
<br><br>


<table BORDER CELLSPACING=0 CELLPADDING=3>

    
<tr>

        
<td colspan=5>
eg.ArithmeticColumnFixture
</td>

    
</tr>

    
<tr>

        
<td>
x
</td>

        
<td>
y
</td>

        
<td>
plus()
</td>

        
<td>
times()
</td>

        
<td>
divide()
</td>

        
<td>
floating()
</td>

    
</tr>

    
<tr>

        
<td>
2
</td>

        
<td>
3
</td>

        
<td bgcolor="#cfffcf">
5
</td>

        
<td bgcolor="#cfffcf">
6
</td>

        
<td bgcolor="#cfffcf">
0
</td>

        
<td bgcolor="#cfffcf">
0.6666667
</td>

    
</tr>

    
<tr>

        
<td>
0
</td>

        
<td>
0
</td>

        
<td bgcolor="#cfffcf">
0
</td>

        
<td bgcolor="#cfffcf">
0
</td>

        
<td bgcolor="#cfffcf">
error
</td>

        
<td bgcolor="#ffcfcf">
error <font size=-1 color="#c08080"><i>expected</i></font><hr>NaN <font size=-1 color="#c08080"><i>actual</i></font>
</td>

    
</tr>

    
<tr>

        
<td>
0
</td>

        
<td>
0
</td>

        
<td bgcolor="#cfffcf">
0
</td>

        
<td bgcolor="#cfffcf">
0
</td>

        
<td>
 <font color="#808080">error</font>
</td>

        
<td>
 <font color="#808080">NaN</font>
</td>

    
</tr>

    
<tr>

        
<td>
200
</td>

        
<td>
300
</td>

        
<td bgcolor="#cfffcf">
500
</td>

        
<td bgcolor="#cfffcf">
60000
</td>

        
<td bgcolor="#cfffcf">
0
</td>

        
<td bgcolor="#cfffcf">
0.6666667
</td>

    
</tr>

    
<tr>

        
<td>
2
</td>

        
<td>
3
</td>

        
<td bgcolor="#ffcfcf">
10 <font size=-1 color="#c08080"><i>expected</i></font><hr>5 <font size=-1 color="#c08080"><i>actual</i></font>
</td>

        
<td bgcolor="#ffcfcf">
10 <font size=-1 color="#c08080"><i>expected</i></font><hr>6 <font size=-1 color="#c08080"><i>actual</i></font>
</td>

        
<td bgcolor="#ffcfcf">
10 <font size=-1 color="#c08080"><i>expected</i></font><hr>0 <font size=-1 color="#c08080"><i>actual</i></font>
</td>

    
</tr>

    
<tr>

        
<td>
200
</td>

        
<td>
3
</td>

        
<td bgcolor="#ffcfcf">
5 <font size=-1 color="#c08080"><i>expected</i></font><hr>203 <font size=-1 color="#c08080"><i>actual</i></font>
</td>

        
<td bgcolor="#ffcfcf">
6 <font size=-1 color="#c08080"><i>expected</i></font><hr>600 <font size=-1 color="#c08080"><i>actual</i></font>
</td>

        
<td bgcolor="#ffcfcf">
0 <font size=-1 color="#c08080"><i>expected</i></font><hr>66 <font size=-1 color="#c08080"><i>actual</i></font>
</td>

        
<td bgcolor="#ffcfcf">
0.6666667 <font size=-1 color="#c08080"><i>expected</i></font><hr>66.6666667 <font size=-1 color="#c08080"><i>actual</i></font>
</td>

    
</tr>

    
<tr>

        
<td>
2
</td>

        
<td>
-3
</td>

        
<td bgcolor="#cfffcf">
-1
</td>

        
<td bgcolor="#cfffcf">
-6
</td>

        
<td bgcolor="#cfffcf">
-0
</td>

        
<td bgcolor="#cfffcf">
-0.6666667
</td>

    
</tr>


</table>


<br><br>



<table BORDER CELLSPACING=0 CELLPADDING=3>


<tr>


<td COLSPAN="2">
eg.Summary
</td>


</tr>


<tr>


<td>
 <font color="#808080">counts</font>
</td>


<td bgcolor="#ffcfcf">
37 right, 10 wrong, 0 ignored, 2 exceptions
</td>

</tr>


<tr>


<td>
 <font color="#808080">run date</font>
</td>


<td>
 <font color="#808080">Thu Feb 21 14:48:50 GMT+0100 2008</font>
</td>

</tr>


<tr>


<td>
 <font color="#808080">run elapsed time</font>
</td>


<td>
 <font color="#808080">0:00.03</font>
</td>

</tr>

</table>




<p>Document prepaired by Ward Cunningham
<br>First Version July 11, 2002
<br>Last Update August 17, 2002
</body>
</html>

